package com.heer.gymnasium.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.heer.gymnasium.AppHelper;


/**
 * 数据保存
 */
public class SysSharePres {

    /**
     * sharedpreferences存储的名称
     */
    private static final String PRES_NAME = "system_share";

    private SharedPreferences mSharePres;

    /**
     * 用户是否是第一次安装APP true 是的 false不是
     */
    private static final String USER_ISFIRSTDOWNLOAD = "user_isfirstdownload";

    /**
     * 用户第一次安装APP 进入首页面时 操作提示 true是的 false不是
     */
    private static final String USER_FIRSTREMINDHOME = "user_firstremindhome";

    /**
     * 用户第一次安装APP 进入地图页面时 操作提示 true是的 false不是
     */
    private static final String USER_FIRSTREMINDMAP = "user_firstremindmap";

    /**
     * 用户是否登录 true 登录 false 未登录
     */
    private static final String USER_LOGIN = "user_login";

    /*用户是否随便看看*/
    private static final String USER_LOOK = "user_look";

    /**
     * 用户是否设置了密保问题
     */
    private static final String USER_SAFETYPROBLEM = "user_SafetyProblem";

    /**
     * SessionId 后面请求的时候回传
     */
    private static final String SESSIONKEY = "sessionKey";

    /**
     * 是否打开手势密码
     */
    public static final String ISOPENGESTURE = "isOpenGesture";

    /**
     * 用户设置的手势密码
     */
    private static final String USER_GESTURE = "user_gesture";

    /**
     * 用户id
     */
    private static final String USER_ID = "user_id";

    /**
     * 用户真实姓名
     */
    private static final String USER_TRUENAME = "user_true_name";

    /**
     * 用户身份证号
     */
    private static final String USER_IDCARD = "user_idcard";

    /**
     * 用户昵称
     */
    private static final String USER_NAME = "user_name";

    /**
     * 用户登录账号
     */
    private static final String USER_ACCOUNT = "user_account";

    /**
     * 用户手机号
     */
    private static final String USER_PHONE = "user_phone";

    /**
     * 用户等级
     */
    private static final String USER_LEVEL = "user_level";

    /**
     * 用户认证状态
     */
    private static final String USER_IDENTIFIED = "user_identified";

    /**
     * 手势密码验证机会
     */
    private static final String USER_GESTURE_CHANCE = "user_gesture_chance";

    /**
     * 用户头像URL
     */
    private static final String USER_PIC_URL = "user_pic_url";

    /**
     * 本地头像地址
     */
    private static final String USER_LOACAL_URL = "user_loacal_url";

    /**
     * 用户云信账号
     */
    private static final String YX_ACCID = "yx_acc_id";

    /**
     * 用户云信token
     */
    private static final String YX_TOKEN = "yx_token";

    /**
     * 是否直播
     */
    private static final String IS_BOARD_ROOM = "is_board_room";

    public static final String YS_TOKEN="ys_token";
    public static final String YS_EXPIRE="ys_expire";

    /**
     * 用户微信openid
     */
    public static final String USER_OPENID = "user_openid";

    /**
     * 用户微信unionid
     */
    public static final String USER_UNIONID = "user_unionid";
    /**
     * <默认构造函数>
     */
    public SysSharePres() {
        mSharePres = AppHelper.context().getSharedPreferences(PRES_NAME, Context.MODE_PRIVATE);
    }


    public void setYsToken(String token) {
        mSharePres.edit().putString(YS_TOKEN, token).apply();
    }

    public String getYsToken() {
        return mSharePres.getString(YS_TOKEN, "");
    }

    public void setYsExpire(int expire) {
        mSharePres.edit().putInt(YS_EXPIRE, expire).apply();
    }

    public int getYsExpire() {
        return mSharePres.getInt(YS_EXPIRE,0);
    }

    private static class SysSharePresHolder {

        static final SysSharePres INSTANCE = new SysSharePres();
    }

    public static SysSharePres getInstance() {
        return SysSharePresHolder.INSTANCE;
    }

    public void setUserIsfirstDownload(boolean user_isfirstdownload) {
        mSharePres.edit().putBoolean(USER_ISFIRSTDOWNLOAD, user_isfirstdownload).apply();
    }

    public boolean getUserIsfirstDownload() {
        return mSharePres.getBoolean(USER_ISFIRSTDOWNLOAD, true);
    }

    public void setUserFirstRemindHome(boolean user_firstremindhome) {
        mSharePres.edit().putBoolean(USER_FIRSTREMINDHOME, user_firstremindhome).apply();
    }

    public boolean getUserFirstRemindHome() {
        return mSharePres.getBoolean(USER_FIRSTREMINDHOME, true);
    }

    public void setUserFirstRemindMap(boolean user_firstremindmap) {
        mSharePres.edit().putBoolean(USER_FIRSTREMINDMAP, user_firstremindmap).apply();
    }

    public boolean getUserFirstRemindMap() {
        return mSharePres.getBoolean(USER_FIRSTREMINDMAP, true);
    }

    public void setUserIsLogin(boolean user_login) {
        mSharePres.edit().putBoolean(USER_LOGIN, user_login).apply();
    }

    public boolean getUserIsLogin() {
        return mSharePres.getBoolean(USER_LOGIN, false);
    }

    public void setUserSafetyproblem(boolean user_SafetyProblem) {
        mSharePres.edit().putBoolean(USER_SAFETYPROBLEM, user_SafetyProblem).apply();
    }

    public boolean getUserSafetyproblem() {
        return mSharePres.getBoolean(USER_SAFETYPROBLEM, false);
    }

    public void setSessionKey(String sessionKey) {
        mSharePres.edit().putString(SESSIONKEY, sessionKey).apply();
    }

    public String getSessionKey() {
        return mSharePres.getString(SESSIONKEY, "");
    }

    public void setUserGesture(String user_gesture) {
        mSharePres.edit().putString(USER_GESTURE, user_gesture).apply();
    }

    public String getUserGesture() {
        return mSharePres.getString(USER_GESTURE, "");
    }

    public void setIsOpenGesture(boolean isopengesture) {
        mSharePres.edit().putBoolean(ISOPENGESTURE, isopengesture).apply();
    }

    public boolean getIsOpenGesture() {
        return mSharePres.getBoolean(ISOPENGESTURE, false);
    }

    public void setUserId(String user_id) {
        mSharePres.edit().putString(USER_ID, user_id).apply();
    }

    public String getUserId() {
        return mSharePres.getString(USER_ID, "");
    }

    public void setUserPicUrl(String user_pic_url) {
        mSharePres.edit().putString(USER_PIC_URL, user_pic_url).apply();
    }

    public String getUserPicUrl() {
        return mSharePres.getString(USER_PIC_URL, "");
    }

    public void setUserLocalUrl(String user_loacal_url) {
        mSharePres.edit().putString(USER_LOACAL_URL, user_loacal_url).apply();
    }

    public String getUserLocalUrl() {
        return mSharePres.getString(USER_LOACAL_URL, "");
    }

    public void setUserTrueName(String user_true_name) {
        mSharePres.edit().putString(USER_TRUENAME, user_true_name).apply();
    }

    public String getUserTrueName() {
        return mSharePres.getString(USER_TRUENAME, "");
    }

    public void setUserIdCard(String user_idcard) {
        mSharePres.edit().putString(USER_IDCARD, user_idcard).apply();
    }

    public String getUserIdCard() {
        return mSharePres.getString(USER_IDCARD, "");
    }

    public void setUserName(String user_name) {
        mSharePres.edit().putString(USER_NAME, user_name).apply();
    }

    public String getUserName() {
        return mSharePres.getString(USER_NAME, "");
    }

    public void setUserAccount(String user_account) {
        mSharePres.edit().putString(USER_ACCOUNT, user_account).apply();
    }

    public String getUserAccount() {
        return mSharePres.getString(USER_ACCOUNT, "");
    }

    public void setUserPhone(String user_phone) {
        mSharePres.edit().putString(USER_PHONE, user_phone).apply();
    }

    public String getUserPhone() {
        return mSharePres.getString(USER_PHONE, "");
    }

    public void setUserLevel(String user_level) {
        mSharePres.edit().putString(USER_LEVEL, user_level).apply();
    }

    public String getUserLevel() {
        return mSharePres.getString(USER_LEVEL, "");
    }

    public void setUserIdentified(int user_identified) {
        mSharePres.edit().putInt(USER_IDENTIFIED, user_identified).apply();
    }

    public int getUserIdentified() {
        return mSharePres.getInt(USER_IDENTIFIED, 0);
    }

    public void setUserGestureChance(int user_gesture_chance) {
        mSharePres.edit().putInt(USER_GESTURE_CHANCE, user_gesture_chance).apply();
    }

    public int getUserGestureChance() {
        return mSharePres.getInt(USER_GESTURE_CHANCE, 5);
    }

    public boolean getUserIsLook() {
        return mSharePres.getBoolean(USER_LOOK, false);
    }

    public void setUserIsLook(boolean userLook) {
        mSharePres.edit().putBoolean(USER_LOOK, userLook).apply();
    }

    public void setYxAccid(String accid){
        mSharePres.edit().putString(YX_ACCID, accid).apply();
    }

    public String getYxAccid(){
        return mSharePres.getString(YX_ACCID,null);
    }

    public void setYxToken(String token){
        mSharePres.edit().putString(YX_TOKEN, token).apply();
    }

    public String getYxToken(){
        return mSharePres.getString(YX_TOKEN,null);
    }

    public void setIsBoardroom(String isBoardroom){
        mSharePres.edit().putString(IS_BOARD_ROOM, isBoardroom).apply();
    }

    public String getIsBoardRoom(){
        return mSharePres.getString(IS_BOARD_ROOM,null);
    }

    public String getUserOpenid() {
        return mSharePres.getString(USER_OPENID, "");
    }

    public void setUserOpenid(String user_openid) {
        mSharePres.edit().putString(USER_OPENID, user_openid).apply();
    }

    public String getUserUnionid() {
        return mSharePres.getString(USER_UNIONID, "");
    }

    public void setUserUnionid(String user_unionid) {
        mSharePres.edit().putString(USER_UNIONID, user_unionid).apply();
    }
}
